package com.base.web.core.config.shiro;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:接收配置文件的拦截配置
 *
 * @Author: rentie
 * @Date: 2018/8/10 14:17
 */
public class ShiroFilters {

        private Logger logger = LoggerFactory.getLogger(ShiroFilters.class);

        private Map<String, Url> filters = new LinkedHashMap<>();

        public static class Url {

            private List<String> urls = new ArrayList<>();

            public List<String> getUrls() {
                return urls;
            }

            public void setUrls(List<String> urls) {
                this.urls = urls;
            }
        }

        public Map<String, Url> getFilters() {
            return filters;
        }

        public void setFilters(Map<String, Url> filters) {
            this.filters = filters;
        }

        public Map<String, String> getFilterMap() {

            Map<String, String> filterMap = new LinkedHashMap<String, String>();

            this.filters.forEach((k, v) -> {
                List<String> urls = v.getUrls();
                urls.forEach(u -> {
                    logger.info("shiro过滤器配置: {}", u + " = " + k);
                    filterMap.put(u, k);
                });

            });

            return filterMap;


        }

}